package com.action.boot.jpa.controller;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;

/**
 * Created by Wuxiang on 2017/3/27.
 * Spring Boot自带定时任务功能，只需一个注解即可完成定时任务功能。
 * @EnableScheduling 开启定时任务
 */
@Controller
//@EnableScheduling
public class SchedulingController {

    @Scheduled(cron = "*/10 * * * * *")
    public void cron() {
        System.out.println("every 10 sec by cron");
    }

    @Scheduled(fixedDelay = 5000)
    public void fixedDelay() {
        System.out.println("every 5 sec by fixedDelay");
    }

    @Scheduled(fixedRate = 2000)
    public void fixedRate() {
        System.out.println("every 2 sec by fixedRate");
    }
}
